<extend name="Public/base"/>

<block name="body">
<!-- 标题栏 -->
  <div class="main-title">
    <h2>{$meta_title}</h2>
  </div>
  <div class="cf">
    <span class="text-danger">（修改店铺所在地时,省市区之间以空格隔开）</span>
  </div>
<link rel="stylesheet" type="text/css" href="__CSS__/store.css?15031711">
<form action="{:U()}" method="post" class="form-horizontal">
  <table border="0" cellpadding="0" cellspacing="0" class="store-joinin" style="width:920px">
    <thead>
      <tr>
        <th colspan="40">店铺详细地址信息</th>
      </tr>
    </thead>
    <tbody>
      <tr style="background: rgb(255, 255, 255);">
        <th style="width:173px">店铺所在地：</th>
        <!-- <td><input type="text" name="address" value="{$data.address}" /></td> -->
        <td>{:Hook('areaSelect',array('province'=>$arr['province'],'city'=>$arr['city'],'district'=>$arr['district'] ))}</td>
        <th style="width:173px">店铺详细地址：</th>
        <td colspan="20"><input type="text" name="address_detail" value="{$data.address_info}" style="min-width:200px" /></td>
        <th>地铺所在经纬度：</th>
        <td>纬度：{$data.lat}<br/>经度：{$data.lng}</td>
      </tr>
      <tr>
        <td colspan="40" style="text-align:center">
          <input type="hidden" name="member_id" value="{$member_id}" />
          <button class="btn submit-btn ajax-post" type="submit" target-form="form-horizontal">修 改</button>
        </td>
      </tr>
    </tbody>
  </table>
</form>
  <table border="0" cellpadding="0" cellspacing="0" style="width:920px">
    <tbody>
      <tr>
        <td><div class="mapbox" id="allmap" style="height:500px;width:100%"></div></td>
      </tr>
    </tbody>
  </table> 
  
</block>

<block name="script">
<script src="http://api.map.baidu.com/api?v=2.0&ak=iToiAqxiGgBGr2rmmFiXjmSHIQRr3zRk"></script>
  <script type="text/javascript">
    //导航高亮
    highlight_subnav("{:U('Store/index')}");
    // 百度地图API功能
     var map = new BMap.Map("allmap");
      map.centerAndZoom(new BMap.Point("{$data.lng}","{$data.lat}"),16);
      map.enableScrollWheelZoom(true);
    var new_point = new BMap.Point("{$data.lng}","{$data.lat}");
    var myIcon = new BMap.Icon('http://api0.map.bdimg.com/images/marker_red_sprite.png',new BMap.Size(40,24));
    var marker = new BMap.Marker(new_point,{icon:myIcon});  // 创建标注
      map.addOverlay(marker);              // 将标注添加到地图中
      map.centerAndZoom(new_point, 20);
      marker.enableDragging();//标记点可拖拽
    var address = "{$data.address_info}";
    var opts = {
      width : 200,     // 信息窗口宽度
      height: 100,     // 信息窗口高度
      title : "店铺地址" , // 信息窗口标题
      enableMessage:true,//设置允许信息窗发送短息
      message:""
    }
    
    //百度地图自定义函数
    function showInfo(e){
        var lng = e.point.lng;
        var lat = e.point.lat;
        $.ajax({
          url:"{:U('Store/getAddresInfoByLngLat')}",
          data:{lat:lat,lng:lng},
          dataType:'json',
          type:'post',
          success: function(res){
             $('input[name=address_detail]').val(res);
             var infoWindow = new BMap.InfoWindow("地址："+res, opts);  // 创建信息窗口对象 
             var point = new BMap.Point( '"'+ lng + ',' + lat + '"');
             map.openInfoWindow(infoWindow,point); //开启信息窗口
          }
        });
        
    }
    map.addEventListener("click", showInfo);
  </script>
</block>
